<template>
    <div class="addClassify">
      <van-nav-bar
        title="添加分类"
        left-arrow
        left-text="返回" 
        @click-left="onClickLeft"
     />
     <div class="add_container">
        <div class="add_input">
        <el-input class="name_input" v-model="name" placeholder="请输入自定义分类名称" />
         <img @click="clearClick" src="../../../static/appimg/icon_delete.png" alt="" style="width:16px;height:16px"/>
       </div>
     </div>
     <div class="save" @click="inStoreClick">保存</div>
    </div>
</template>
<script>
export default {
    data(){
        return{
         name:'',
        }
    },
    methods:{
        onClickLeft(){
            this.$router.go(-1)
        },
        inStoreClick(){
             axios.post(`/own/category/update`,{name:this.name}).then(response => {
              if(response.data.msg.code == 0){
                this.$message({
                message: '添加分类成功',
                type: 'success',
                duration:1000,
                });
                this.$router.push( "/shangpinguanli/classify" )
              }else{
                this.$message.error(response.data.msg.info);
              }
            });
        },
        clearClick(){
            this.name = ""
        }
    }
    
}
</script>
<style scoped lang="less">
.addClassify{
    width: 100%;
    height: 100%;
    background: #F6F8FB;
    position: absolute;
    display: flex;
    flex-direction: column;
}
.add_container{
    width: 100%;
    height: 51px;
    padding: 15px;
}
.add_input{
    width: 100%;
    height: 51px;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    border-radius: 10px;
    padding: 0 10px;
}
.save{
    width: calc(100% - 30px);
    height: 46px;
    background: #005AFF;
    font-size: 16px;
    color: white;
    text-align: center;
    line-height: 46px;
    border-radius: 15px;
    position: absolute;
    bottom: 15px;
    left: 15px;
}
/deep/ .add_input .name_input .el-input__inner{
    width: 300px !important;
    background: white !important;
    height: 50px;
    border: 0 !important;
    border-radius: 10px !important;
}
/deep/ .van-nav-bar__text{
  color: black !important;
}
/deep/ .van-nav-bar .van-icon {
  color: black !important;
}
</style>